﻿' NuGardt API Helper JSON
' Copyright (C) 2013 NuGardt Software
' http://www.nugardt.com
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program.  If not, see <http://www.gnu.org/licenses/>.
'
Imports System.Runtime.Serialization
Imports System.Net

Namespace API.Helper.JSON
  ''' <summary>
  ''' Base class for results.
  ''' </summary>
  ''' <remarks></remarks>
  <DataContract()>
  Public MustInherit Class BaseResult
    Implements IBaseResult

    Private m_CacheExpires As Nullable(Of DateTime)
    Private m_ResponseRaw As String

    ''' <summary>
    ''' Constructor.
    ''' </summary>
    ''' <remarks></remarks>
    Public Sub New()
      Me.m_CacheExpires = Nothing
      Me.m_ResponseRaw = Nothing
    End Sub

    Protected Friend MustOverride Sub ReadHeader(ByVal Headers As WebHeaderCollection) Implements IBaseResult.ReadHeader

#Region "Properties"

    ''' <summary>
    ''' Returns the date when the cached data expires. Only available when caching is enabled.
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    <IgnoreDataMember()>
    Public Property CacheExpires As Nullable(Of DateTime) Implements IBaseResult.CacheExpires
      Get
        Return Me.m_CacheExpires
      End Get
      Friend Set(ByVal Value As Nullable(Of DateTime))
        Me.m_CacheExpires = Value
      End Set
    End Property

    ''' <summary>
    ''' Returns the raw response from the server.
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    <IgnoreDataMember()>
    Public Property ResponseRaw As String Implements IBaseResult.ResponseRaw
      Get
        Return Me.m_ResponseRaw
      End Get
      Friend Set(ByVal Value As String)
        Me.m_ResponseRaw = Value
      End Set
    End Property

#End Region
  End Class
End Namespace